package com.langshixiaobai.domain.service.trial.factory;

import com.langshixiaobai.domain.model.entity.MarketProductEntity;
import com.langshixiaobai.domain.model.entity.TrialBalanceEntity;
import com.langshixiaobai.domain.model.valobj.GroupBuyActivityDiscountVO;
import com.langshixiaobai.domain.model.valobj.SkuVO;
import com.langshixiaobai.domain.service.trial.AbstractGroupBuyMarketSupport;
import com.langshixiaobai.domain.service.trial.node.RootNode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

//策略工厂
@Service
public class DefaultActivityStrategyFactory {

    //根节点
    private RootNode rootNode;
    //初始化
    public DefaultActivityStrategyFactory(RootNode rootNode){
        this.rootNode = rootNode;
    }

    // 返回根节点
    public AbstractGroupBuyMarketSupport<MarketProductEntity, DynamicContext, TrialBalanceEntity> strategyHandler(){

        return rootNode;
    }

    // 上下文资源
    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class DynamicContext{
        // 拼团活动营销配置值对象
        private GroupBuyActivityDiscountVO groupBuyActivityDiscountVO;
        // 商品信息
        private SkuVO skuVO;
        // 折扣价格
        private BigDecimal deductionPrice;
    }

}
